package com.mutual.reins.verify.controller;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mutual.reins.danger.entity.PrptDangerUnit;
import com.mutual.reins.danger.service.IPrptDangerUnitService;
import com.mutual.reins.interf.entity.*;
import com.mutual.reins.interf.service.IReinsInterFlogService;
import com.mutual.reins.interf.service.IReinsPolicyUnitService;
import com.mutual.reins.verify.service.IVerifyPrptDangerUnitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zjl
 */

@Api("投保单检查调用接口")
@RestController
@RequestMapping("/reins")
@Slf4j
public class VerifyPrptDangerUnitController {
    @Autowired
    private IVerifyPrptDangerUnitService iVerifyPrptDangerUnitService;
    @Autowired
    private IReinsInterFlogService iReinsInterFlogService;
    @Autowired
    private IReinsPolicyUnitService iReinsPolicyUnitService;
    @Autowired
    private IPrptDangerUnitService iPrptDangerUnitService;

    @ApiOperation("测试投保单检查")
    @PostMapping("/VerifyPrptDangerUnit/{cerTiNo}")
    public Map<String,PrptDangerUnit>  verifyPrptDangerUnit(@PathVariable("cerTiNo") String cerTiNo) throws InstantiationException, IllegalAccessException {
        List<String> keyList = new ArrayList<>();
        keyList.add("T16052016010100000026");
        keyList.add("T01012016010100000034");
        QueryWrapper queryWrapper  = new QueryWrapper<>();
        queryWrapper.in("PROPOSALNO",keyList);
        List<PrptDangerUnit> prptDangerUnitList = iPrptDangerUnitService.list(queryWrapper);
        Map<String,PrptDangerUnit> prptDangerUnitMap = new HashMap<>(1);
        if(ObjectUtil.isNotNull(prptDangerUnitList) && !prptDangerUnitList.isEmpty()){
            for(PrptDangerUnit prptDangerUnit:prptDangerUnitList){
                prptDangerUnitMap.put(prptDangerUnit.getProposalNo()+"-"+prptDangerUnit.getDangerNo(),prptDangerUnit);
            }
        }
        return prptDangerUnitMap;

    }
}
